﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;

public partial class Control_INewsInfo_Top : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ControlDataInit();
    }


    #region ControlDataInit
    protected void ControlDataInit()
    {
        string INewsID;
        
        if(Request.QueryString["INewsID"]==null)
        {
            Response.Redirect("INews.aspx");
        }
        else
        {
            INewsID = Request.QueryString["INewsID"].ToString();

            string SQLstr = "SELECT INews.*, INewsClass.INC_Title FROM (INews INNER JOIN INewsClass ON ";
            SQLstr += "INews.IN_ClassID = INewsClass.INC_ID) WHERE (INews.IN_ID = " + INewsID + ")";

            DataTable DT_INews = AccHelper.GetDataTable(SQLstr);

            if (DT_INews.Rows[0]["IN_Thumbnail"].ToString() == "")
            {
                IMG_ProductImage.ImageUrl = "~/Manageweb/images/null.jpg";
            }
            else
            {
                IMG_ProductImage.ImageUrl = "~/UploadImage/" + DT_INews.Rows[0]["IN_Thumbnail"].ToString();
            }

            LB_Class.Text = DT_INews.Rows[0]["INC_Title"].ToString();
            LB_Content.Text = DT_INews.Rows[0]["IN_Content"].ToString();
            LB_DateTime.Text = DT_INews.Rows[0]["IN_DateTime"].ToString();
            LB_Title.Text = DT_INews.Rows[0]["IN_Title"].ToString();
        }
    }
    #endregion


    #region 产品图片 [格式化]
    protected string FormatImage(object _Image)
    {
        string ImageURL = Convert.ToString(_Image);

        if (ImageURL == "")
        {
            return "Manageweb/images/null.jpg";
        }
        else
        {
            return "UploadImage/" + ImageURL;
        }
    }
    #endregion
}
